Zebrad: add rollback tip height command - #28
Conversation
3dea123 to
35a1f92
Compare
35a1f92 to
c9c4ee9
Compare
|
Swap-and-restore instead of in-place finalized mutation is the right call. Two on the staking replay:
|
|
Nice, this looks like it addresses the staking replay concerns from my earlier comment. The one test gap I still see is checkpoint replay end-to-end: the new test covers the helper path, but not a staking block driven through both non-finalized and checkpoint/finalized replay with equal bond rewards/value pools. I think that would be worth adding. One separate rollback edge: Testing: |
e1ca96c to
e7c5e70
Compare
- Address the issue that the commit that caused this regression was trying to address, but in a different way that is less likely to expose a memory leak
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
API
---
```
{ "CreateNewDelegationBond": { "amount_zats": <power-of-10 zat value>, "target_finalizer": "<32-byte finalizer ID>" }, }
{ "RetargetDelegationBond": { "bond_key": "<32-byte bond pubkey>", "target_finalizer": "<32-byte finalizer ID>" }, }
{ "BeginDelegationUnbonding": { "bond_key": "<32-byte bond pubkey>" }, }
{ "WithdrawDelegationBond": { "bond_key": "<32-byte bond pubkey>" }, }
```
Example Usage
-------------
First, create a bond:
```sh
$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "wallet_staking_action", "params": [{"CreateNewDelegationBond": { "amount_zats": 100000000, "target_finalizer": "f18b65c340e048dfd4e9c104fbdbbd842e026c87e657318b8c69270288170cd4" }}], "id": 1}' http://127.0.0.1:8232/
{"jsonrpc":"2.0","id":1,"result":"{ \"txid\": 2b795c1abdc811027fdc11b48d4ed14725be79181b481d3d740927eae0ab4b8b, \"staking_action\": StakingAction { kind: \"CreateNewDelegationBond\", unique_public_key: \"f8416a451081e1b3b33ca032f0cc4195bbe8daf9cfd6c834399ffbb73908b3e8\", challenge: \"0000000000000000000000000000000000000000000000000000000000000000\", signature: \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\", target_finalizer: \"f18b65c340e048dfd4e9c104fbdbbd842e026c87e657318b8c69270288170cd4\", amount_zats: 100000000 } }"}
```
Then, use the `unique_public_key` from that result as the `bond_key` for retargeting:
```
$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "wallet_staking_action", "params": [{"RetargetDelegationBond": { "bond_key": "f8416a451081e1b3b33ca032f0cc4195bbe8daf9cfd6c834
399ffbb73908b3e8", "target_finalizer": "904a343aa5a8a6bf3e930acc12bc7755d68b0ed7fb70cc28e6ae6268d7d197cd" }}], "id": 1}' http://127.0.0.1:8232/
{"jsonrpc":"2.0","id":1,"result":"{ \"txid\": 852655308157bb99ff0bbc4439a3350cbfce309360bcb7059835c008408a4d8b, \"staking_action\": StakingAction { kind: \"RetargetDelegationBond\", unique_public_key: \"f8416a451081e1b3b33ca032f0cc4195bbe8daf9cfd6c834399ffbb73908b3e8\", challenge: \"0000000000000000000000000000000000000000000000000000000000000000\", signature: \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\", target_finalizer: \"904a343aa5a8a6bf3e930acc12bc7755d68b0ed7fb70cc28e6ae6268d7d197cd\" } }"}
```
e7c5e70 to
c78ac72
Compare
Adds
zebrad rollback-tip-height --height <height>to safely roll back local state by rebuilding a bounded copy through verified block replay, then atomically swapping it into place while keeping the previous state as a backup.Added it because during sync I would sometimes get stuck on a local branch when mining was enabled, which would then force me to restart the process.
Also invalidates tip-dependent GUI wallet/Zaino caches after rollback and fixes staking/delegation replay during checkpoint copying so rebuilt state preserves accounting correctly.